using Holoville.HOTween;
using Holoville.HOTween.Core;
using UnityEngine;

public class MsgScaleToCenter : MessageBase
{
	public UILabel lbTxtF;

	public UILabel lbTxtBack;

	public float animationTimeBeforeParticle = 2f;

	public float stayOnScreenTime = 2f;

	public float animationTimeAfterParticle = 2f;

	public Vector3 Scale;

	[HideInInspector]
	public float _alpha;

	public override void SetColor(Color clF, Color clB)
	{
		lbTxtF.color = clF;
		lbTxtBack.color = clB;
	}

	public override void SetText(string text)
	{
		lbTxtF.text = text;
		lbTxtBack.text = text;
	}

	public override void SetTime(float val)
	{
		stayOnScreenTime = val;
	}

	public override void StartMessage()
	{
		HOTween.Init();
		lbTxtF.gameObject.SetActive(true);
		UpdateAlpha(0f);
		lbTxtF.transform.localScale = Vector3.one * 2f;
		HOTween.Kill(lbTxtF.transform);
		HOTween.To(lbTxtF.transform, animationTimeBeforeParticle, new TweenParms().Prop("localScale", Scale).UpdateType(UpdateType.TimeScaleIndependentUpdate).OnComplete(DeactivateIndicator));
		HOTween.To(this, animationTimeBeforeParticle, new TweenParms().Prop("_alpha", 1f).OnUpdate((TweenDelegate.TweenCallback)delegate
		{
			UpdateAlpha(_alpha);
		}));
	}

	public override void Wait()
	{
		lbTxtF.gameObject.SetActive(false);
	}

	public void DeactivateIndicator()
	{
		Invoke("Delay", stayOnScreenTime);
	}

	private void Delay()
	{
		HOTween.Kill(lbTxtF.transform);
		HOTween.To(lbTxtF.transform, animationTimeAfterParticle, new TweenParms().Prop("localScale", Vector3.one * 0.01f).UpdateType(UpdateType.TimeScaleIndependentUpdate).OnComplete(Reset));
		HOTween.To(this, animationTimeAfterParticle, new TweenParms().Prop("_alpha", 0f).OnUpdate((TweenDelegate.TweenCallback)delegate
		{
			UpdateAlpha(_alpha);
		}));
	}

	private void UpdateAlpha(float val)
	{
		lbTxtF.alpha = val;
		lbTxtBack.alpha = val;
	}

	public void Reset()
	{
		MessageManager.OnCompleteMessage(this);
	}
}
